package com.yh.ldzl.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.yh.ldzl.domain.QcDefect;
import com.yh.ldzl.mapper.QcDefectMapper;
import com.yh.ldzl.service.QcDefectService;
import com.yh.ldzl.service.QcIndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class QcDefectServiceImpl implements QcDefectService {

    @Autowired
    private QcDefectMapper QcDefectMapper;

    @Override
    public IPage<QcDefect> selectQcDefectList(String defect_name,
                                              String index_type,
                                              String defect_level,
                                              int pageNum,
                                              int pageSize) {

        Page<QcDefect> page = new Page<>(pageNum, pageSize);

        return QcDefectMapper.selectQcDefectList(page, defect_name,index_type,defect_level);
    }

    @Override
    public List<Map<String, Object>> selectQcDefectType() {
        return QcDefectMapper.selectQcDefectType();
    }

    @Override
    public boolean insertQcDefect(QcDefect qcDefect) {
        qcDefect.setCreate_by(SecurityUtils.getUsername());
        return QcDefectMapper.insertQcDefect(qcDefect)>0 ;
    }

    @Override
    public boolean updateQcDefect(QcDefect qcDefect) {
        qcDefect.setUpdate_by(SecurityUtils.getUsername());
        return QcDefectMapper.updateQcDefect(qcDefect)>0 ;
    }

    @Override
    public boolean deleteQcDefect(List<Long> ids) {
        return QcDefectMapper.deleteQcDefect(ids)>0;
    }
}
